package com.sdehua.wear.service.impl;

import com.sdehua.wear.entity.TicketManager;
import com.sdehua.wear.dao.TicketManagerDao;
import com.sdehua.wear.service.TicketManagerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketManager)表服务实现类
 *
 * @author makejava
 * @since 2022-01-03 21:11:21
 */
@Service("ticketManagerService")
public class TicketManagerServiceImpl implements TicketManagerService {
    @Resource
    private TicketManagerDao ticketManagerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TicketManager queryById(Integer id) {
        return this.ticketManagerDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketManager> queryAllByLimit(int offset, int limit) {
        return this.ticketManagerDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketManager 实例对象
     * @return 实例对象
     */
    @Override
    public TicketManager insert(TicketManager ticketManager) {
        this.ticketManagerDao.insert(ticketManager);
        return ticketManager;
    }

    /**
     * 修改数据
     *
     * @param ticketManager 实例对象
     * @return 实例对象
     */
    @Override
    public TicketManager update(TicketManager ticketManager) {
        this.ticketManagerDao.update(ticketManager);
        return this.queryById(ticketManager.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.ticketManagerDao.deleteById(id) > 0;
    }
}